#ifndef TASK_H
#define TASK_H

#include "vfs.h"
#include "paging.h"

typedef struct thread
{
	//u32int id;		//the thread ID.
	u32int entry;		//instruction pointer
	u32int started;//has this thread ever been started in the first place?
	u32int esp;		//stack pointer
	u32int ebp;

	struct thread* next;	//next thread in the linked list

}thread_t;

typedef struct task
{
	u32int id;		//the task ID
	s8int* name;
	s8int level;				//the tasks priortiy level (between 1 and 255).
	s8int starvation;		//starvation level (should never be higher than the priority).

	address_space_t* address_space;

	fs_node_t* stdin;//standard streams
	fs_node_t* stdout;

	thread_t* first_thread;	//the first thread in the linked list of threads

	thread_t* current_thread; //a s16intcut pointer to the current thread that is running
	thread_t* next_thread; //a s16intcut pointer to the next thread to be run

	struct task* next;
	struct task* prev;
}task_t;

void task_exit(void);
int task_exec(s8int* path);
int task_create(s8int* name, u32int entry);
int task_level(s8int level);

void init_tasking(void);
void init_task_interface(void);

void task_switch(void);
#endif
